package patienceSSO.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import patienceCommon.pojo.User;
import patienceSSO.dao.UserDao;

@Service
public class UserServiceImp implements UserService{
	@Autowired
	private UserDao userDao;
	
	@Override
	public List<User> landing(String account, String password) {
		QueryWrapper<User> queryWrapper=new QueryWrapper<User>();
		queryWrapper.eq("account", account);
		queryWrapper.eq("password", password);
		
		List<User> list = userDao.selectList(queryWrapper);
		
		return list;
	}

	@Override
	public int add(String account,String username,String password,String phone,String email) {
		User entity=new User();
		entity.setAccount(account);
		entity.setUsername(username);
		entity.setPassWord(password);
		entity.setPhone(phone);
		entity.setEmail(email);
		
		int count = userDao.insert(entity);
		
		return count;
	}

	@Override
	public List<User> check(String account, String email) {
		QueryWrapper<User> queryWrapper=new QueryWrapper<User>();
		if(StringUtils.isNotBlank(account)) {
			queryWrapper.eq("account", account);
		}
		if(StringUtils.isNotBlank(email)) {
			queryWrapper.eq("email", email);
		}
		
		List<User> list = userDao.selectList(queryWrapper);
		
		return list;
	}


}
